import Vue from 'vue'
import Vuex from 'vuex'
import { getItem, setItem } from '@/utils/storage.js'
Vue.use(Vuex)
const TOKEN = 'TOUTIAO_USER'
export default new Vuex.Store({
  state: {
    // 用户的登录状态信息
    // 获取本地数据
    // user: JSON.parse(window.localStorage.getItem('TOUTIAO_USER'))
    user: getItem(TOKEN) || ''

    // user: null
  },
  mutations: {
    setUser (state, user) {
      // console.log('user', user)
      state.user = user
      // 保存本地数据
      // window.localStorage.setItem('TOUTIAO_USER', JSON.stringify(user))
      setItem(TOKEN)
    }
  },
  actions: {
  },
  modules: {
  }
})
